package com.Service.impl;

import com.Service.MedicalCardService;
import com.dao.MedicalCardMapper;
import com.model.pojo.MedicalCard;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Service
public class MedicalCardServiceImpl implements MedicalCardService {
    @Resource
    private MedicalCardMapper medicalCardMapper;

    public MedicalCard settlement(double price,String cardid,String listingSerialNumber,HttpSession session){

        MedicalCard m=medicalCardMapper.settlement(cardid);

        if(Integer.valueOf(m.getMedicalCardBalance())>price){

            price=(double)Integer.valueOf(m.getMedicalCardBalance())-price;
            boolean bl=medicalCardMapper.Modify(price,cardid,listingSerialNumber);
            if(bl==true){
                session.setAttribute("judge","成功");

            }else{
                session.setAttribute("judge","失败");
            }


        }else{


            session.setAttribute("yue","余额不足");
        }

        return m;
    }

    @Override
    public boolean amount(String cardid1,double amount) {
        boolean bl =medicalCardMapper.amount(cardid1,amount);

        return bl;
    }

}
